home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / compute / 1988_02 / burger.pas < prev    next >
Pascal/Delphi Source File  |  1987-10-01  |  13KB  |  489 lines

  1. program Burger_Blaster;
  2.  
  3. {Copyright 1988 COMPUTE! Publications, Inc. All rights reserved.}
  4.  
  5. {$C- }
  6.  
  7. {$i Graph.p }    { ░▒▓█ Turbo Pascal extra graphics commands █▓▒░ }
  8.  
  9. const
  10.    total = 5;
  11.    bmake : array[1..total,0..6] of integer =
  12.            ((3,3,1,2,0,0,0),(4,3,1,4,2,0,0),(4,3,1,5,2,0,0),
  13.             (5,3,1,3,1,2,0),(5,3,1,4,5,2,0));
  14.  
  15. type
  16.    stype = string[20];
  17.    data1 = record
  18.               shape     : array [0..150] of integer;
  19.            end;
  20.    data2 = record
  21.               x,y,d,shp : integer;
  22.            end;
  23.  
  24. var
  25.    nfile       : text;
  26.    sh1         : array [0..11] of data1;
  27.    sh2         : array [1..10] of data2;
  28.    i,r,c,tx,td,
  29.    score,miss,
  30.    level,
  31.    burgeron,
  32.    burgernum,
  33.    shoot,sx,sy,
  34.    burg,hotdog : integer;
  35.    ch          : char;
  36.    chaa        : stype;
  37.  
  38. function st(h :integer) : stype;
  39. begin
  40.    str(h,chaa);
  41.    st := chaa;
  42. end;
  43.  
  44. {$i letters.p }    { ░▒▓█ letter and number generator █▓▒░ }
  45.  
  46. procedure inkey;
  47. begin
  48.    if keypressed
  49.       then read(kbd,ch)
  50.       else ch := #0;
  51.    if (upcase(ch)='Q') and not keypressed
  52.       then
  53.          begin
  54.             textmode(c80);
  55.             textcolor(7);
  56.             clrscr;
  57.             halt;
  58.          end;
  59. end;
  60.  
  61.  
  62. procedure getshapes;
  63. begin
  64.    assign(nfile,'burger.shp');
  65.    reset(nfile);
  66.    for i := 1 to 9 do
  67.       with sh1[i] do
  68.          begin
  69.             read(nfile,shape[0]);
  70.             read(nfile,shape[1]);
  71.             read(nfile,shape[2]);
  72.             c := (((shape[1]+3)div 4)*shape[2]*2+6)div 3;
  73.             for r := 3 to c-1 do
  74.                read(nfile,shape[r]);
  75.          end;
  76.    close(nfile);
  77. end;
  78.  
  79.  
  80. procedure titlescreen;
  81. begin
  82.    graphcolormode;
  83.    palette(2);
  84.    graphbackground(1);
  85.    clearscreen;
  86.    getpic(sh1[0].shape,0,0,19,4);
  87.    getpic(sh1[11].shape,0,0,19,9);
  88.    gotoxy(1,25);
  89.    for r := 0 to 80 do
  90.       for i := 192 to 199 do
  91.          for c := 0 to 5 do
  92.             if getdotcolor(r,i)<>0
  93.                then draw(r*4,(i-192)*5+c,r*4+3,(i-192)*5+c,3);
  94.    gotoxy(1,25); write(' ':10);
  95.    putletter(110,10,3,'Burger Blaster');
  96.    putletter(15,40,1,'Copyright 1988 COMPUTE! Publications, Inc.');
  97.    putletter(90,49,1,'All rights reserved.');
  98.    putletter(90,80,2,'Press return to play');
  99.    for i := 1 to 5 do
  100.       with sh1[i] do
  101.          begin
  102.             putpic(shape,50,i*20+74);
  103.             for r := 1 to 25 do
  104.                putletter(r*7+63,i*20+70,4,'.');
  105.          end;
  106.    putpic(sh1[9].shape,80,194);
  107.    putletter(245,90,4,'burger');
  108.    putletter(245,110,4,'top bun');
  109.    putletter(245,130,4,'bottom bun');
  110.    putletter(245,150,4,'lettuce');
  111.    putletter(245,170,4,'tomato');
  112.    putletter(110,190,4,concat('hot dog -',#26,' extra points'));
  113.    repeat
  114.       inkey;
  115.    until ch=#13;
  116.    clearscreen;
  117. end;
  118.  
  119.  
  120. procedure resetgame;
  121. begin
  122.    score := 0;
  123.    miss := 5;
  124.    tx := 150;
  125.    level := 1;
  126.    burgeron := 0;
  127.    hotdog := 0;
  128.    td := 0;
  129.    burg := 0;
  130.    shoot := 0;
  131.    for i := 1 to 10 do
  132.       with sh2[i] do
  133.          begin
  134.             x := 0;
  135.             y := 0;
  136.             d := 0;
  137.             shp := 0;
  138.          end;
  139. end;
  140.  
  141.  
  142. procedure drawscore;
  143. begin
  144.    putletter(30,185,2,'score ');
  145.    putletter(72,185,2,'      ');
  146.    putletter(72,185,5,st(score));
  147. end;
  148.  
  149.  
  150. procedure drawmake;
  151. begin
  152.    for i:=1 to burgernum do putpic(sh1[0].shape,0,i*5+50);
  153.    burgernum := bmake[level,0];
  154.    for i := 1 to burgernum do
  155.       with sh1[bmake[level,burgernum+1-i]] do
  156.          putpic(shape,0,i*5+50);
  157.    for i := 1 to 10 do
  158.       begin
  159.          if i/2=int(i/2)
  160.             then
  161.                begin
  162.                   sound(1000);
  163.                   delay(40);
  164.                   nosound;
  165.                   putletter(0,40,1,'make');
  166.                end
  167.             else putletter(0,40,2,'make');
  168.          delay(200);
  169.       end;
  170. end;
  171.  
  172.  
  173. procedure drawscreen;
  174. begin
  175.    clearscreen;
  176.    draw(30,7,319,7,2); draw(319,7,319,182,2);
  177.    draw(319,182,30,182,2); draw(30,182,30,7,2);
  178.    for i := 179 to 180 do
  179.       begin
  180.          draw(52,i,tx-1,i,1);
  181.          draw(tx+24,i,297,i,1);
  182.       end;
  183.    putletter(120,0,9,'burger blaster');
  184.    putletter(170,185,2,'chances left ');
  185.    putletter(261,185,5,st(miss));
  186.    drawscore;
  187.    putpic(sh1[8].shape,tx,181);
  188.    getpic(sh1[10],tx,177,tx+35,181);
  189.    putpic(sh1[6].shape,32,181);
  190.    putpic(sh1[7].shape,298,181);
  191.    putletter(0,195,3,'q');
  192.    putletter(c,195,6,'uit  ');
  193.    putletter(c,195,3,'Space');
  194.    putletter(c,195,6,' fire  ');
  195.    chaa := concat(#27,'     ',#26);
  196.    putletter(c,195,3,chaa);
  197.    putletter(c-35,195,4,'and');
  198.    putletter(c+21,195,6,'move');
  199.    putletter(c,195,3,'   return ');
  200.    putletter(c,195,6,'stop');
  201.    putletter(0,40,1,'make');
  202.    burgernum:=1;
  203.    drawmake;
  204.    putletter(90,90,8,'press any key to start');
  205.    repeat
  206.       inkey;
  207.    until ch<>#0;
  208.    putletter(90,90,7,'                      ');
  209. end;
  210.  
  211.  
  212. procedure hotdoghit;
  213. begin
  214.    with sh2[i] do
  215.       begin
  216.          putpic(sh1[11].shape,x,y);
  217.          putletter(x,y,7,'100');
  218.          for c := 1 to 100 do
  219.             begin
  220.                sound(random(1000)+30);
  221.                delay(random(3));
  222.                nosound;
  223.             end;
  224.          hotdog := 0;
  225.          shp := 0;
  226.          score := score + 100;
  227.          drawscore;
  228.          putletter(x,y,7,'   ');
  229.       end;
  230. end;
  231.  
  232.  
  233. procedure checkshot;
  234. begin
  235.    for i := 1 to 10 do
  236.       with sh2[i] do
  237.          if shp>0
  238.             then
  239.                begin
  240.                  if (abs((x+10)-(sx+10))<15) and (abs(y-2-sy)<10) and (shoot=1)
  241.                     then
  242.                        begin
  243.                           if shp=9
  244.                              then hotdoghit
  245.                              else
  246.                                 begin
  247.                                    shp := -shp;
  248.                                    for r := 1 to 400 do
  249.                                    sound(random(1000)+30);
  250.                                 end;
  251.                           shoot := 0;
  252.                           nosound;
  253.                        end;
  254.                end;
  255. end;
  256.  
  257.  
  258. procedure shootgun;
  259. begin
  260.    draw(sx,sy,sx,sy-5,0);
  261.    draw(sx+18,sy,sx+18,sy-5,0);
  262.    sy := sy - 3;
  263.    checkshot;
  264.    if sy<12
  265.       then shoot := 0
  266.       else if shoot<>0
  267.               then
  268.                  begin
  269.                     draw(sx,sy,sx,sy-5,1);
  270.                     draw(sx+18,sy,sx+18,sy-5,1);
  271.                  end;
  272. end;
  273.  
  274.  
  275. procedure drawburgers;
  276. begin
  277.    for i := 1 to burgeron do
  278.       with sh1[bmake[level,i]] do
  279.          putpic(shape,tx+8,179-((i-1)*5));
  280.    getpic(sh1[10],tx,179-(i*5),tx+35,181);
  281. end;
  282.  
  283.  
  284. procedure movetray;
  285. begin
  286.    if ((ch=#27) and keypressed) or (td<>0)
  287.       then
  288.          begin
  289.             if keypressed
  290.                then read(kbd,ch);
  291.             if ((ch='K') or (td=1)) and (tx>55)
  292.                then
  293.                   begin
  294.                      td := 1;
  295.                      tx := tx - 1;
  296.                   end;
  297.             if ((ch='M') or (td=-1)) and (tx<260)
  298.                then
  299.                   begin
  300.                      td := -1;
  301.                      tx := tx + 1;
  302.                   end;
  303.             putpic(sh1[10].shape,tx,181);
  304.          end;
  305.    if ch=#13
  306.       then td := 0;
  307.    if (ch=' ') and (shoot=0)
  308.       then
  309.          begin
  310.             shoot := 1;
  311.             sx := tx + 7;
  312.             sy := 176 - (burgeron*5);
  313.             td := 0;
  314.             for i := 1000 downto 500 do
  315.                sound(i);
  316.             nosound;
  317.          end;
  318.    if shoot=1
  319.       then shootgun;
  320. end;
  321.  
  322.  
  323. procedure nextround;
  324. begin
  325.    putletter(186,90,3,'                 ');
  326.    putletter(100,90,3,'round completed');
  327.    for i := 600 downto 100 do
  328.       begin
  329.          sound(i);
  330.          delay(5);
  331.       end;
  332.    nosound;
  333.    putletter(100,90,3,'               ');
  334.    level := level + 1;
  335.    for i := 1 to burgeron do
  336.       putpic(sh1[0].shape,tx+8,179-((i-1)*5));
  337.    putpic(sh1[8].shape,tx,181);
  338.    getpic(sh1[10],tx,177,tx+35,181);
  339.    burgeron := 0;
  340.    if level>total
  341.       then level := 1;
  342.    drawmake;
  343. end;
  344.  
  345.  
  346. procedure correctland;
  347. begin
  348.    with sh2[burg] do
  349.       begin
  350.          if (abs(x+10-(tx+15))<10) and (bmake[level,burgeron+1]=abs(shp))
  351.             then
  352.                begin
  353.                   putletter(x,y-14,7,'   ');
  354.                   putletter(x,y-14,7,st(abs(d)*5));
  355.                   sound(1000);
  356.                   delay(20);
  357.                   nosound;
  358.                   burgeron := burgeron + 1;
  359.                   score := score + (abs(d)*5);
  360.                   drawscore;
  361.                   drawburgers;
  362.                   delay(200);
  363.                   putletter(x,y-14,7,'   ');
  364.                   if burgeron=burgernum
  365.                      then nextround;
  366.                end
  367.             else
  368.                begin
  369.                   for i := 90 to 105 do
  370.                      draw(100,i,226,i,0);
  371.                   if bmake[level,burgeron+1]<>abs(shp)
  372.                      then putletter(100,90,2,'   wrong piece    ')
  373.                      else putletter(100,95,2,' missed the catch ');
  374.                   sound(800);
  375.                   delay(60);
  376.                   nosound;
  377.                   miss := miss - 1;
  378.                   putletter(261,185,5,'  ');
  379.                   putletter(261,185,5,st(miss));
  380.                   delay(400);
  381.                   if bmake[level,burgeron+1]<>abs(shp)
  382.                      then putletter(100,90,2,'                  ')
  383.                      else putletter(100,95,2,'                  ');
  384.                end;
  385.       end;
  386. end;
  387.  
  388.  
  389. procedure burgermove;
  390. begin
  391.    burg := burg + 1;
  392.    if burg>10
  393.       then burg := 1;
  394.    with sh2[burg] do
  395.       begin
  396.          if (shp=0) and (random(100)<4)
  397.             then
  398.                begin
  399.                   shp := random(6)+1;
  400.                   if (shp=6) and (hotdog=1)
  401.                      then shp := random(5)+1
  402.                      else if shp=6
  403.                              then
  404.                                 begin
  405.                                    shp := 9;
  406.                                    hotdog := 1;
  407.                                 end;
  408.                   y := random(76)+33;
  409.                   if shp=9
  410.                      then d := random(8)+8
  411.                      else d := random(15)+1;
  412.                   x := 35;
  413.                   if random<0.4
  414.                      then
  415.                         begin
  416.                            d := -d;
  417.                            x := 290;
  418.                         end;
  419.                end;
  420.          if shp>0
  421.             then
  422.                begin
  423.                   if shp=9
  424.                      then putpic(sh1[11].shape,x,y)
  425.                      else putpic(sh1[0].shape,x,y);
  426.                   x := x + d;
  427.                   if d<0
  428.                      then x := x - abs(td*2)
  429.                      else if d>0
  430.                              then x := x + abs(td*2);
  431.                   if (random(100)<4) and (shp=9)
  432.                      then d := -d;
  433.                   if (x<35) or (x>290)
  434.                      then
  435.                         begin
  436.                            if shp=9
  437.                               then hotdog := 0;
  438.                            shp := 0;
  439.                         end
  440.                      else
  441.                         begin
  442.                            if shp=9
  443.                              then putpic(sh1[9].shape,x,y)
  444.                              else putpic(sh1[shp].shape,x,y);
  445.                         end;
  446.                end
  447.             else if shp<0
  448.                    then
  449.                       begin
  450.                          putpic(sh1[0].shape,x,y);
  451.                          y := y + random(3)+2;
  452.                          if y>176-(burgeron*5)
  453.                             then
  454.                                begin
  455.                                   correctland;
  456.                                   shp := 0;
  457.                                end
  458.                             else putpic(sh1[abs(shp)].shape,x,y);
  459.                       end;
  460.       end;
  461. end;
  462.  
  463.  
  464. begin
  465.    getshapes;
  466.    titlescreen;
  467.    repeat
  468.       resetgame;
  469.       drawscreen;
  470.       repeat
  471.          inkey;
  472.          movetray;
  473.          burgermove;
  474.       until miss=0;
  475.       putletter(124,90,2,' game over ');
  476.       putletter(90,97,3, 'press space to play again');
  477.       putletter(93,104,3,'or any other key to quit');
  478.       repeat
  479.          if keypressed
  480.             then read(kbd,ch);    { ░▒▓█ clear keyboard buffer █▓▒░ }
  481.       until not keypressed;
  482.       repeat
  483.          inkey;
  484.       until ch<>#0;
  485.    until ch<>' ';
  486.    textmode(c80);
  487.    textcolor(7);
  488.    clrscr;
  489. end.